#include "wxshtmleasyprinting.h"
#include <wx/html/htmprint.h>

namespace {
  wxsRegisterItem<wxsHtmlEasyPrinting> Reg( _T( "HtmlEasyPrinting" ), _T( "HtmlEasyPrinting" ), wxsTTool, _T( "工具" ), 75, false );
}

wxsHtmlEasyPrinting::wxsHtmlEasyPrinting( wxsItemResData* Data ):
  wxsTool( Data, &Reg.Info, NULL, NULL ),
  m_sHeader( wxEmptyString ),
  m_sFooter( wxEmptyString ),
  m_iHeaderPages( wxPAGE_ALL ),
  m_iFooterPages( wxPAGE_ALL ) {}


void wxsHtmlEasyPrinting::OnBuildCreatingCode() {
  switch( GetLanguage() ) {
    case wxsCPP: {
      AddHeader( _T( "<wx/html/htmprint.h>" ), GetInfo().ClassName, hfInPCH );
      Codef( _T( "%C(%N, %W);\n" ) );
      if( !m_sHeader.IsEmpty() ) {
        Codef( _T( "%ASetHeader(%s, %d);\n" ), m_sHeader.wx_str(), m_iHeaderPages );
      }
      if( !m_sFooter.IsEmpty() ) {
        Codef( _T( "%ASetHeader(%s, %d);\n" ), m_sFooter.wx_str(), m_iFooterPages );
      }
      BuildSetupWindowCode();
      return;
    }
    case wxsUnknownLanguage:
    default: {
      wxsCodeMarks::Unknown( _T( "wxsHtmlEasyPrinting::OnBuildCreatingCode" ), GetLanguage() );
    }
  }
}

void wxsHtmlEasyPrinting::OnEnumToolProperties( M_Code_unused long Flags ) {
  static const long arrHeaderPages[] = {wxPAGE_ALL, wxPAGE_EVEN, wxPAGE_ODD};
  static const wxChar* arrHeaderPageNames[]  = {wxT( "wxPAGE_ALL" ), wxT( "wxPAGE_EVEN" ), wxT( "wxPAGE_ODD" ), NULL};
  WXS_SHORT_STRING( wxsHtmlEasyPrinting, m_sHeader, _T( "Header" ), _T( "header" ), wxEmptyString, false )
  WXS_SHORT_STRING( wxsHtmlEasyPrinting, m_sFooter, _T( "Footer" ), _T( "footer" ), wxEmptyString, false )
  WXS_ENUM( wxsHtmlEasyPrinting, m_iHeaderPages, _T( "Header Pages" ), _T( "header_pages" ), arrHeaderPages, arrHeaderPageNames, wxPAGE_ALL );
  WXS_ENUM( wxsHtmlEasyPrinting, m_iFooterPages, _T( "Footer Pages" ), _T( "footer_pages" ), arrHeaderPages, arrHeaderPageNames, wxPAGE_ALL );
}
